package com.ruoyi.member.service.impl;

import com.ruoyi.member.domain.Comment;
import com.ruoyi.member.mapper.CommentMapper;
import com.ruoyi.member.service.ICommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;

/**
 * 评论Service业务层处理
 *
 * @author ruoyi
 * @date 2025-01-22
 */
@Service
public class CommentServiceImpl implements ICommentService {

    @Autowired
    private CommentMapper commentMapper;

    /**
     * 查询评论
     *
     * @param commentId 评论主键
     * @return 评论
     */
    @Override
    public Comment selectCommentById(Long commentId) {
        return commentMapper.selectCommentById(commentId);
    }

    /**
     * 查询评论列表
     *
     * @param comment 评论
     * @return 评论集合
     */
    @Override
    public List<Comment> selectCommentList(Comment comment) {
        return commentMapper.selectCommentList(comment);
    }

    /**
     * 新增评论
     *
     * @param comment 评论
     * @return 结果
     */
    @Override
    public int insertComment(Comment comment) {
        comment.setCreateTime(new Date());
        // Comments are visible by default in new design
        return commentMapper.insertComment(comment);
    }

    /**
     * 修改评论
     *
     * @param comment 评论
     * @return 结果
     */
    @Override
    public int updateComment(Comment comment) {
        comment.setUpdateTime(new Date());
        return commentMapper.updateComment(comment);
    }

    /**
     * 批量删除评论
     *
     * @param commentIds 需要删除的评论主键集合
     * @return 结果
     */
    @Override
    public int deleteCommentByIds(Long[] commentIds) {
        return commentMapper.deleteCommentByIds(commentIds);
    }

    /**
     * 删除评论信息
     *
     * @param commentId 评论主键
     * @return 结果
     */
    @Override
    public int deleteCommentById(Long commentId) {
        return commentMapper.deleteCommentById(commentId);
    }

    /**
     * 审核评论
     *
     * @param comment 评论
     * @return 结果
     */
    @Override
    public int auditComment(Comment comment) {
        // TODO: Audit functionality removed in new design
        return commentMapper.updateComment(comment);
    }

    /**
     * 批量通过评论
     *
     * @param commentIds 评论ID数组
     * @return 结果
     */
    @Override
    public int approveComments(Long[] commentIds) {
        // TODO: Audit functionality removed in new design
        // Comments are visible by default without approval
        return 0;
    }

    /**
     * 批量拒绝评论
     *
     * @param commentIds 评论ID数组
     * @return 结果
     */
    @Override
    public int rejectComments(Long[] commentIds) {
        // TODO: Audit functionality removed in new design
        // Use deleteCommentByIds to remove comments instead
        return 0;
    }

    /**
     * 回复评论
     *
     * @param comment 评论
     * @return 结果
     */
    @Override
    public int replyComment(Comment comment) {
        // 设置为回复评论
        comment.setCreateTime(new Date());
        // All comments visible by default in new design
        return commentMapper.insertComment(comment);
    }
}